package com.laiyizhan.common.mapper;

import com.laiyizhan.common.model.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserMapper {
    @Delete({
        "delete from t_user",
        "where user_id = #{userId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long userId);

    @Insert({
        "insert into t_user (user_id, user_name, ",
        "password, sex, mobile, ",
        "avatar, province, ",
        "city, district, ",
        "dan_id, pay_time, ",
        "vh_position, lr_hand, register_time, ",
        "longitude, latitude, ",
        "active_time, private_game, ",
        "enable)",
        "values (#{userId,jdbcType=BIGINT}, #{userName,jdbcType=VARCHAR}, ",
        "#{password,jdbcType=VARCHAR}, #{sex,jdbcType=BIT}, #{mobile,jdbcType=VARCHAR}, ",
        "#{avatar,jdbcType=VARCHAR}, #{province,jdbcType=VARCHAR}, ",
        "#{city,jdbcType=VARCHAR}, #{district,jdbcType=VARCHAR}, ",
        "#{danId,jdbcType=BIGINT}, #{payTime,jdbcType=TIMESTAMP}, ",
        "#{vhPosition,jdbcType=BIT}, #{lrHand,jdbcType=BIT}, #{registerTime,jdbcType=TIMESTAMP}, ",
        "#{longitude,jdbcType=DOUBLE}, #{latitude,jdbcType=DOUBLE}, ",
        "#{activeTime,jdbcType=TIMESTAMP}, #{privateGame,jdbcType=BIT}, ",
        "#{enable,jdbcType=BIT})"
    })
    int insert(User record);

    int insertSelective(User record);

    @Select({
        "select",
        "user_id, user_name, password, sex, mobile, avatar, province, city, district, ",
        "dan_id, pay_time, vh_position, lr_hand, register_time, longitude, latitude, ",
        "active_time, private_game, enable",
        "from t_user",
        "where user_id = #{userId,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    User selectByPrimaryKey(Long userId);

    int updateByPrimaryKeySelective(User record);

    @Update({
        "update t_user",
        "set user_name = #{userName,jdbcType=VARCHAR},",
          "password = #{password,jdbcType=VARCHAR},",
          "sex = #{sex,jdbcType=BIT},",
          "mobile = #{mobile,jdbcType=VARCHAR},",
          "avatar = #{avatar,jdbcType=VARCHAR},",
          "province = #{province,jdbcType=VARCHAR},",
          "city = #{city,jdbcType=VARCHAR},",
          "district = #{district,jdbcType=VARCHAR},",
          "dan_id = #{danId,jdbcType=BIGINT},",
          "pay_time = #{payTime,jdbcType=TIMESTAMP},",
          "vh_position = #{vhPosition,jdbcType=BIT},",
          "lr_hand = #{lrHand,jdbcType=BIT},",
          "register_time = #{registerTime,jdbcType=TIMESTAMP},",
          "longitude = #{longitude,jdbcType=DOUBLE},",
          "latitude = #{latitude,jdbcType=DOUBLE},",
          "active_time = #{activeTime,jdbcType=TIMESTAMP},",
          "private_game = #{privateGame,jdbcType=BIT},",
          "enable = #{enable,jdbcType=BIT}",
        "where user_id = #{userId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(User record);
}